﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartCity.ProcessEngine.API.Infrastructrue.Interfaces
{
    /// <summary>
    /// 仓储接口层
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRespository<T> where T : class
    {
        /// <summary>
        /// 数据库上下文
        /// </summary>
        MyDbcontext DB { get; }

        /// <summary>
        /// 查询方法
        /// </summary>
        /// <returns>返回任务</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 添加方法
        /// </summary>
        /// <param name="t">实体</param>
        /// <returns>返回任务</returns>
        Task<int> AddAsync(T t);
        /// <summary>
        /// 批量添加方法
        /// </summary>
        /// <param name="t">实体集合</param>
        /// <returns>返回批量任务</returns>
        Task<int> AddRege(IEnumerable<T> t);
        /// <summary>
        /// 修改方法
        /// </summary>
        /// <param name="t">实体</param>
        /// <returns>返回任务</returns>
        Task<int> UpdateAsync(T t);
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="t">实体集合</param>
        /// <returns>返回受影响的行数</returns>
        Task<int> UpdateRege(IEnumerable<T> t);
    }
}
